<?php
/********************************************************
 *
 * 此文件的作用:
 *		扩展了的FLEA_Controller_Action类
 *
 * @copyright Copyright (c) 2007-12-20
 * @author 刘昌功 lcg635@126.com
 *
 ********************************************************/
defined('APP_DIR') or die("404 Not Found");

FLEA::loadClass('FLEA_Controller_Action');

class Common_Action extends FLEA_Controller_Action {
	var $tpl = null;	
	var $tplDir = '';
	var $user = null;

	function Common_Action($ctlName) {
		parent::FLEA_Controller_Action($ctlName);
		
		$this->tpl = $this->_getView();		//返回视图对象
		
		$this->tpl->path = TPL;
		$this->tpl->cacheDir = APP_DIR . '/_Cache/';
		$this->tpl->enableCache = false;
		//$rbac = FLEA::getSingleton('FLEA_RBAC');
		//$this->user = $rbac->getUser();
		//$data = array(
		//	'user' => $this->user,
		//	'configs' => FLEA::getAppInf('configs'),
		//	'menus' => FLEA::loadFile('Configs_Menus'),
		//	'header' => TPL . TPL_F . 'header.php',
		//	'footer' => TPL . TPL_F . 'footer.php'
		//);
		//$this->tpl->assign($data);
	}

	//获取地址栏的参数值，即$_GET
	function saveGet($name) {
		if ( !isset($_GET[$name]) )
			return null;
		return intval($_GET[$name]);
	}
	
	function checkLogined() {
		if ($this->user == null || empty($this->user)) {
			setcookie('backurl', $this->_url($_GET['act']), time()+1800, '/');
			js_alert('请先登录', null, url('user', 'login'));
		}
	}

	function _throwRemind($title, $bigTitle, $result, $backUrl) {
		$this->tplDir = TPL_O;
		$veiwData = array(
			'title' => $title,
			'bigTitle' => $bigTitle,
			'result' => $result,
			'backUrl' => $backUrl
		);
		$this->_out('remind', $veiwData);
	}

	//将数据传给View层
	function _out($file, $viewData = null) {
		$this->tpl->assign($viewData);
		$this->tpl->display($this->tplDir . $file . '.php');
		exit();
	}
}
